<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldQueue;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

abstract class Job implements SelfHandling, ShouldQueue
{
    /*
    |--------------------------------------------------------------------------
    | Queueable Jobs
    |--------------------------------------------------------------------------
    |
    | This job base class provides a central location to place any logic that
    | is shared across all of your jobs. The trait included with the class
    | provides access to the "queueOn" and "delay" queue helper methods.
    |
    */

    use InteractsWithQueue, Queueable, SerializesModels;

    protected $job_name ='Job1';
    protected $logger = null;

    public function __construct()
    {
        $this->InitLogger();
    }

    private function InitLogger(){
        $this->logger = new Logger($this->job_name);
        $this->logger->pushHandler(new \Monolog\Handler\RotatingFileHandler(app()->storagePath().'/logs/jobs/'.$this->job_name.'.log',5, Logger::INFO));
    }
}
